/***************************************************************
Copyright Statement:

This software/firmware and related documentation (EcoNet Software) 
are protected under relevant copyright laws. The information contained herein 
is confidential and proprietary to EcoNet (HK) Limited (EcoNet) and/or 
its licensors. Without the prior written permission of EcoNet and/or its licensors, 
any reproduction, modification, use or disclosure of EcoNet Software, and 
information contained herein, in whole or in part, shall be strictly prohibited.

EcoNet (HK) Limited  EcoNet. ALL RIGHTS RESERVED.

BY OPENING OR USING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY 
ACKNOWLEDGES AND AGREES THAT THE SOFTWARE/FIRMWARE AND ITS 
DOCUMENTATIONS (ECONET SOFTWARE) RECEIVED FROM ECONET 
AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON AN AS IS 
BASIS ONLY. ECONET EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, 
WHETHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 
OR NON-INFRINGEMENT. NOR DOES ECONET PROVIDE ANY WARRANTY 
WHATSOEVER WITH RESPECT TO THE SOFTWARE OF ANY THIRD PARTIES WHICH 
MAY BE USED BY, INCORPORATED IN, OR SUPPLIED WITH THE ECONET SOFTWARE. 
RECEIVER AGREES TO LOOK ONLY TO SUCH THIRD PARTIES FOR ANY AND ALL 
WARRANTY CLAIMS RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES 
THAT IT IS RECEIVERS SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD 
PARTY ALL PROPER LICENSES CONTAINED IN ECONET SOFTWARE.

ECONET SHALL NOT BE RESPONSIBLE FOR ANY ECONET SOFTWARE RELEASES 
MADE TO RECEIVERS SPECIFICATION OR CONFORMING TO A PARTICULAR 
STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND 
ECONET'S ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE ECONET 
SOFTWARE RELEASED HEREUNDER SHALL BE, AT ECONET'S SOLE OPTION, TO 
REVISE OR REPLACE THE ECONET SOFTWARE AT ISSUE OR REFUND ANY SOFTWARE 
LICENSE FEES OR SERVICE CHARGES PAID BY RECEIVER TO ECONET FOR SUCH 
ECONET SOFTWARE.
***************************************************************/
#ifndef _OMCI_ADAPT_COMMON_H_
#define _OMCI_ADAPT_COMMON_H_


/************************************************************************
*                  I N C L U D E S
*************************************************************************
*/

#include <stdint.h>
#include <stddef.h>
#include <time.h>

#include "omci_internal_export.h"
#include "xpon_ioctl_if.h"
#include "libapi_ponmgr_v2.h"
#include "omci_me_private.h"
#include <net/if.h>
#include "libapi_lib_switchmgr.h"
#include "mtkswitch_api.h"
#include "omci_check_memory_leak.h"
#ifdef TCSUPPORT_OPENWRT
#include "uci.h" 
#endif
#include "xpon_map_public.h"


/************************************************************************
*                  D E F I N E S   &   C O N S T A N T S
*************************************************************************
*/

#define LINK_UP			1
#define LINK_DOWN		0
#define XPON_COMMON_NODE  		            "XPON_Common"
#define XPON_COMMON_ATTR_TRAFFIC_STA  	    "trafficStatus"
#define ONU_WAN_DATA_LINK_UP 				"up"
#define ONU_WAN_DATA_LINK_DOWN 				"down"
#define DEFAULT_CONFIG_PATH					"/etc/config"

#define DIR_UP      	 0
#define DIR_DOWN         1

#define OMCI_EXT_CONT_LEN_MIN  44

// It is truly a disaster to define  these addresses(offset) randomly
// Always a good habit to define them in the same  place, for easy understanding and less opportunity to mess up with the flash layout

#define OMCI_PONMGR_CMD	                    "/userfs/bin/ponmgr_cfg "
#define OMCI_BRCTL_CMD	                    "/usr/bin/brctl "
#define OMCI_IFCONFIG_CMD	                "/sbin/ifconfig "

//tcapi set attronite
#define GPONCOMMONNODE 		                "GPON_Common"
#define CURRENTATTRIBUTE 		            "CurrentAttribute"
#define OMCI_SOFTWAREIMAGE_STATE       		"OMCI_SoftWare_Image_State"
#define GPON_OMCI_ENTRY					    "OMCI_Entry"
#define PMGR_ATTR_MACBRIDGEPORT_PREFIX	    "macBridgePort" //set prefix of mac bridge port attribute in GPON_OMCI_ENTRY node
#define OMCI_RTP_PM_RTPERROR                "rtpError"
#define OMCI_RTP_PM_PacketLoss		        "packetLossRate"
#define OMCI_RTP_PM_MaxJitter	            "maxJitter"
#define OMCI_RTP_PM_MaxTimeBetRTCP          "maxRTCPInterval"
#define OMCI_RTP_PM_BUFUNDERFLOW            "bufUnderflow"
#define OMCI_RTP_PM_BUFOVERFLOW             "bufOverflow"
#define PMGR_ATTR_TOTALGEMPORT	            "totalGemPort"


#define PONCOMMON_ATTR_XPON_PHY_STATUS	    "phyStatus"
#define PONCOMMON_XPON_PHY_DOWN			    "down"
#define PONCOMMON_XPON_PHY_GPON_DOWN	    "gpon_phy_down"
#define PONCOMMON_XPON_PHY_GPON_UP		    "gpon_phy_up"
#define PONCOMMON_ATTR_DATA_TRAFFIC_STA  	"trafficStatus"
#define ONU_WAN_DATA_LINK_UP 				"up"
#define ONU_WAN_DATA_LINK_DOWN 				"down"

#define MAX_INST_COUNT			            512
/*only used in omci adapter, not stardard performace*/
#define OMCI_GET_NO_VALUE 			        0xf0   //used attr get functions, if function valid and not get valid attr value, return this  
#define OMCI_GET_INSTANC_BY_ATTR_MAX_NUM    10
/*9.3.10*/
#define MAX_OMCI_PBIT_NUM	                8 //8 kinds pbit


#define MAX_OMCI_ANI_PORT_NUM	            GPON_MAX_ANI_INTERFACE
#define MAX_OMCI_ANI_PORT_VALID_NUM	        2
#define OMCI_ANI_PORT_INST_ID_INDEX	        0
#define OMCI_ANI_PORT_VALID_INDEX	        1

#define GPON_HANDLE_PON_IFC_DEF			    0 //default
#define GPON_HANDLE_PON_IFC_CREATE		    1
#define GPON_HANDLE_PON_IFC_DEL			    2
#define GPON_HANDLE_PON_IFC_MODIFY		    3
#define GPON_HANDLE_PON_IFC_UNASSIGN	    4 //unassign gemport in this inteface

#define OMCI_PPTP_UNI_STATE_UNLOCK          0
#define OMCI_PPTP_UNI_STATE_LOCK            1

/*for set device id in PM*/
#define PM_LAN_INTERFACE_0			        0
#define PM_WAN_INTERFACE_1		            1

#define TCONT_POLICY_SP 	                1
#define TCONT_POLICY_WRR	                2

#define OMCI_ONU_ID_MAX_NUM_1G              256
#define OMCI_ONU_ID_MAX_NUM_10G             1024

#define OMCI_TLS_INVALID_PORT               0xFF
#define OMCI_TLS_INVALID_VLAN               4096

#define LANPORT_INFO_MAX_PORT				8

#define OMCI_MAX_TABLE_SIZE		4096 //maybe should set a bigger value?
enum omciMacBridgePort_status{
	OMCI_MAC_BRIDGE_PORT_FAIL= -1,
	OMCI_MAC_BRIDGE_PORT_SUCCESS=0,		
	OMCI_MAC_BRIDGE_PORT_ENTRY_NOT_FOUND=2,
	OMCI_MAC_BRIDGE_PORT_ENTRY_EXIST=3
};


typedef struct omci_global_info_s
{
	int	onuType;
	uint16_t onuId;
	uint8_t trafficStatus;
	uni_port_info_t omci_port_map[OMCI_MAX_PORTS];
}omci_global_info_t,*omci_global_info_ptr;


typedef struct omci_onu_capablity_s
{
	uint8_t 	omccVersion;
	int  linkMode;
}omci_onu_capablity_t, *omci_onu_capablity_ptr;


typedef struct setNode_s{
    char nodeName[32];
    char attName[32];
    char val[32];
}setNode_t,*setNode_p;


typedef enum{
	PON_OLT_FIBERHOME_551601 = 1,
	PON_OLT_DASAN ,

	/* add new olt type id before here */
}PON_OltType_t;

typedef struct {
	char *oltName;
	PON_OltType_t  oltId;
}PON_OltTypeInfo_t;

extern int oltTypeId;
extern uint8_t pmIntervalTimes;
extern int olt_ctrl_qos_flag;

#define isFiberhome_551601  (oltTypeId == PON_OLT_FIBERHOME_551601)
#define isDasan			(oltTypeId == PON_OLT_DASAN)

typedef struct {
    uint32_t  BaseOmciMsgRx;
    uint32_t  ExtOmciMsgRx;
}OmciPktRxCnt_t;

extern OmciPktRxCnt_t OmciPktRxCnt;


/************************************************************************
*                  M A C R O S
*************************************************************************
*/



/************************************************************************
*                  D A T A     T Y P E S
*************************************************************************
*/


typedef struct _management_entry * management_entry_ptr;
typedef struct omci_attr_dscp_s * omci_attr_dscp_ptr;

/* For set/get function type of each me attribute. */
typedef int(*get_val_func)(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
typedef int(*set_val_func)(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);

/* For set/get operation of each me attribute. */
typedef struct _attribute_func
{
	get_val_func get_val;
	set_val_func set_val;
}attribute_func_t, *attribute_func_ptr;

/* Attribute description list for each me class. */
typedef struct omci_attr_dscp_s
{
    uint8_t   attriIndex;
    uint8_t   attriName[128];
    uint16_t  attriLen;//0:un-inited;    0: variable length
	uint8_t   attriAccess;//R, W, R/W.....
	uint8_t   format;//POINTTER;BIT_FIELD...
    uint8_t   support;
    attribute_func_t *func;
}omci_attr_dscp_t;

/* General operations for each me class. */
typedef int(*me_action_func)(management_entry_ptr me_entry, omci_me_info_ptr me_info);

typedef struct _operation_func
{
	me_action_func create_me;
	me_action_func delete_me;
	me_action_func set_attrs;
	me_action_func get_attrs;
	me_action_func get_cur_attrs;
	me_action_func test_me;
}omci_me_func_t, *omci_me_func_ptr;

typedef struct GNU_PACKED omci_attr_s
{
    uint8_t *attrData;
    uint16_t   attrLen;
}omci_attr_t, *omci_attr_ptr;

/*pm data struct*/

typedef struct MACBridgePmCounters_s
{
	uint32_t learnEntryDiscardCnts;
}MACBridgePmCounters_t;
/*9.3.9 mac bridge port performance monitoring history data ME*/
typedef struct MACBridgePortPmCounters_s
{
	uint32_t forwardFrameCnts;
	uint32_t delayExceededDiscardCnts;
	uint32_t mtuExceededDiscardCnts;
	uint32_t receivedFrameCnts;
	uint32_t receivedDiscardCnts;
}MACBridgePortPmCounters_t;
/*9.3.30 ethernet frame performance monitoring history data upstream 
   or 9.3.31 ethernet frame performance monitoring history data downstream*/
 /*9.3.32 Ethernet Frame Extended PM ME*/
 /*9.3.34 Ethernet Frame Extended 64bit PM ME*/
typedef struct GNU_PACKED EthFramePmStreamCounters_s
{
	uint64_t dropEvents;
	uint64_t octets;
	uint64_t packets;
	uint64_t broadcastPkts;
	uint64_t multicastPkts;
	uint64_t crcErroredPkts;
	uint64_t undersizePkts;
	uint64_t oversizePkts;
	uint64_t pkts64Octets;
	uint64_t pkts127Octets;
	uint64_t pkts255Octets;
	uint64_t pkts511Octets;
	uint64_t pkts1023Octets;
	uint64_t pkts1518Octets;	
}EthFramePmStreamCounters_t;

typedef struct PPTPEthernetUNIPmcounters_s
{
	uint32_t FCSErrors;
	uint32_t excessiveCollisionCnts;
	uint32_t lateCollisionCnts;
	uint32_t framesTooLong;
	uint32_t bufferOverFlowOnRcv;
	uint32_t singleCollisionFrameCnts;
	uint32_t multiCollisionFrameCnts;
	uint32_t deferredTransmissionCnts;
	uint32_t alignmentErrorCnts;
}PPTPEthernetUNIPmcounters_t;

typedef struct PPTPEthernetUNI3Pmcounters_s
{
	uint32_t dropEvents;
	uint32_t octets;
	uint32_t packets;
	uint32_t broadcastPkts;
	uint32_t multicastPkts;
	uint32_t undersizePkts;
	uint32_t fragments;
	uint32_t jabbers;
	uint32_t pkts64Octets;
	uint32_t pkts65To127Octets;
	uint32_t pkts128To255Octets;
	uint32_t pkts256To511Octets;
	uint32_t pkts512To1023Octets;
	uint32_t pkts1024To1518Octets;
}PPTPEthernetUNI3Pmcounters_t;

typedef struct PPTPEthernetUNI4Pmcounters_s
{
	uint32_t transmitted_traffic;
	uint32_t received_traffic;
	uint32_t transmitted_rate;
	uint32_t received_rate;
	uint32_t transmitted_Octets;
	uint32_t received_Octets;
	uint32_t transmitted_dis_cout;
	uint32_t received_dis_cout;
	uint32_t transmitted_err_cout;
	uint32_t received_err_cout;
}PPTPEthernetUNI4Pmcounters_t;
typedef struct CallCtrlPmcounters_s
{
	uint32_t SetupFailure;
	uint32_t SetupTimer;
	uint32_t TerminateFailure;
	uint32_t PortRelease;
	uint32_t PortOffhookTimer;
}CallCtrlPmcounters_t;

typedef struct RTPDataPmcounters_s
{
	uint32_t RtpErrors;
	uint32_t PacketLoss;
	uint32_t MaxJitter;
	uint32_t MaxTimeBetRTCP;
	uint32_t BufferUnderflows;
	uint32_t BufferOverflows;
}RTPDataPmcounters_t;

typedef struct SipAgentPmcounters_s
{
    uint32_t Transactions;
    uint32_t RxInviteReqs;
    uint32_t RxInviteRetrans;
    uint32_t RxNoninviteReqs;
    uint32_t RxNoninviteRetrans;
    uint32_t RxResponse;
    uint32_t RxResponseRetransmissions;
    uint32_t TxInviteReqs;
    uint32_t TxInviteRetrans;
    uint32_t TxNonInviteReqs;
    uint32_t TxNonInviteRetrans;
    uint32_t TxResponse;
    uint32_t TxResponseRetransmissions;
    
}SipAgentPmcounters_s_t;


typedef struct SipCallInitPmcounters_s
{
    uint32_t FailedToConnect;
    uint32_t FailedToValidate;
    uint32_t Timeout;
    uint32_t FailureReceived;
    uint32_t FailedToAuthenticate;
    
}SipCallInitPmcounters_t;

typedef struct TotalGemPortPmcounters_s
{
	uint32_t lostFragmentDown;
	uint32_t lostFragmentUp;
	uint64_t receivedFragment;
	uint64_t receivedBlocks;
	uint64_t transmittedBlocks;
	uint32_t impairedBlocks;
	uint64_t transmittedFragment;
	uint32_t badReceivedPackets;
	uint64_t receivedBlocks64;
	uint64_t transmittedBlocks64;
}TotalGemPortPmcounters_t;

typedef struct EthernetTrafficPmcounters_s
{
	uint32_t UpstreamFrames;
	uint32_t DownstreamFrames;
	uint32_t UpstreamBytes;
	uint32_t DownstreamBytes;
	uint32_t DropUpstreamFrames;
	uint32_t DropUpstreamBytes;
	uint32_t DropDownstreamFrames;
	uint32_t MulticastUpstreamFrames;
	uint32_t MulticastDownstreamFrames;
	uint64_t UpstreamBytes64;
	uint64_t DownstreamBytes64;
	uint64_t UpstreamFrames64;
	uint64_t DownstreamFrames64;
}EthernetTrafficPmcounters_t;

typedef struct GEMPortProtocolPmcounters_s
{
	uint32_t lostGEMFragmentCounter;
	uint32_t transmittedGEMFragmentCounter;
}GEMPortProtocolPmcounters_t;

typedef struct EnhancedTCPMcounters_s
{
	uint32_t PSBdHECErrCount;
	uint32_t XGTCHECErrCount;
	uint32_t UnknownProfCount;
	uint64_t TransmitXGEMFrames;
	uint64_t FragmentXGEMFrames;
	uint64_t XGEMHECLostWordCount;
	uint64_t XGEMKeyErrors;
	uint64_t XGEMHECErrCount;
	uint64_t TransmitByteNoidleXGEMFrames;
	uint64_t ReceiveByteNoidleXGEMFrames;
	uint32_t LODSEventCount;
	uint32_t LODSEventRestoreCount;
	uint32_t ONUReactivLODSEvents;
}EnhancedTCPMcounters_t;

typedef struct tca_notify_info_s
{
    uint16_t classId;
    uint16_t instId;
    uint64_t currentData;
    uint64_t threshold;
    uint8_t alarm_num;
    uint8_t reportFlag;
}tca_notify_info_t, *tca_notify_info_ptr;

typedef struct GNU_PACKED pm_history_data_buff_s
{
    union 
    {
    	omci_fec_pm_hist_t fec_pm;
    	omci_mac_br_pm_his_t mac_br_pm;
    	omci_mac_br_port_pm_his_t mac_br_port_pm;
    	omci_eth_frame_pm_his_up_t eth_frame_pm_up;
    	omci_eth_frame_pm_his_down_t eth_frame_pm_down;
    	omci_gemport_net_ctp_pm_his_t gemport_net_ctp_pm;
    	omci_energy_consumption_pm_his_t energy_consumption_pm;
    	omci_gem_port_pm_t gemport_pm;
    	omci_gal_eth_pm_hist_t gal_eth_pm;
    	omci_eth_pm_his_t eth_pm;
    	omci_eth_pm_his_2_t eth2_pm;
    	omci_eth_pm_his_3_t eth3_pm;
    	omci_eth_frame_ext_pm_t eth_frame_ext_pm;
    	omci_eth_frame_ext_pm_64bit_t eth_frame_ext_64bit_pm;
    	omci_ip_host_pm_his_t iphost_pm;
    	omci_call_ctl_pm_hist_t call_ctl_pm;
    	omci_rtp_pm_hist_t rtp_pm;
    	omci_sip_agent_pm_hist_t sip_agent_pm;
    	omci_sip_call_init_pm_hist_t sip_call_init_pm;
    	omci_tcp_udp_pm_his_t tcp_udp_pm;
    	omci_alcatel_eth_traffic_pm_t alcatel_eth_pm;
    	omci_alcatel_total_gemport_pm_t alcatel_total_gem_pm;
    	omci_alcatel_gemport_protocol_pm_t alcatel_gem2_pm;
    	omci_enhanced_fec_pm_hist_t enhanced_fec_pm;
    	omci_enhanced_tc_pm_hist_t enhanced_tc_pm;
    	omci_xgon_tc_pm_hist_t xgpon_tc_pm;
    	omci_xgon_ds_mgnt_pm_hist_t xgpon_ds_mgnt_pm;
    	omci_xgon_us_mgnt_pm_hist_t xgpon_us_mgnt_pm;
	}GNU_PACKED;
}pm_history_data_buff_t, *pm_history_data_buff_ptr;
typedef struct pm_prev_data_buff_s
{
    union{
        PHY_FECCONFIG_t phyFecCnt;
        GEM_STATISTIC_t gponGemCnt;
        MACBridgePmCounters_t macBridge;
        MACBridgePortPmCounters_t macBriPort;
        EthFramePmStreamCounters_t ethFrameUp;
        EthFramePmStreamCounters_t ethFrameDown;
        PPTPEthernetUNIPmcounters_t pptpEthUni;
        PPTPEthernetUNI3Pmcounters_t pptpEth3Uni;
        CallCtrlPmcounters_t callCtrl;
        RTPDataPmcounters_t rtp;
        SipAgentPmcounters_s_t sipAgent;
        SipCallInitPmcounters_t sipCall;
        EthFramePmStreamCounters_t ethFrameExtend;
        EthFramePmStreamCounters_t ethFrameExtend64b;
        TotalGemPortPmcounters_t alcatelTotalGem;
        EthernetTrafficPmcounters_t alcatelEthTraffic;
        GEMPortProtocolPmcounters_t alcatelGem2;
        PHY_FECCONFIG_t enhancedFecCnt;
        EnhancedTCPMcounters_t xgponTc;
        EnhancedTCPMcounters_t enhancedTc; 
        GPON_10G_DS_MGNT_COUNTER_T xgponDsMgnt;
        GPON_10G_US_MGNT_COUNTER_T xgponUsMgnt;
    };
}pm_prev_data_buff_t, pm_prev_data_buff_ptr;

typedef struct extend_pm_ctrl_block_s
{
    uint16_t threshold_id;
    uint16_t parent_me_classId;
    uint16_t parent_me_instId;
    uint16_t accumulation_disable;
    uint16_t tca_disable;
    uint16_t control_field;
    uint16_t tci;
    uint16_t reserved;
}extend_pm_ctrl_block_t, *extend_pm_ctrl_block_ptr;

typedef struct pm_history_data_list_s
{
    struct pm_history_data_list_s *next;
    uint16_t classId;
    uint16_t instId;
    pm_history_data_buff_t pm_data;
    pm_prev_data_buff_t pm_prev_data;
    extend_pm_ctrl_block_t ctrl_block;
}pm_history_data_list_t, *pm_history_data_list_ptr;



/* General description for each me class. */
typedef struct _management_entry
{
	uint16_t omciMeClassId;
	omci_me_func_ptr func;
	omci_attr_dscp_ptr omci_attr_dscp_list;
	omci_attr_ptr attr;
	uint8_t special_flag;
}management_entry_t;



typedef struct commitNode_s{
	char nodeName[32];
	struct commitNode_s *next;
}commitNode_t,*commitNode_p;

typedef struct commitNodeList_s{
	commitNode_p pHeadNode;
	pthread_mutex_t lock;
}commitNodeList_t,*commitNodeList_p;


typedef struct omciTLSInfo_s
{
    unsigned char lanPort;
    unsigned short vlan;
}omciTLSInfo_t, *omciTLSInfo_ptr;

/************************************************************************
*                  D A T A   D E C L A R A T I O N S
*************************************************************************
*/

/************************************************************************
*                  F U N C T I O N    D E C L A R A T I O N S
#                  I N L I N E    F U N C T I O N   D E F I N I T I O N S
*************************************************************************
*/


int omci_adpt_delay_omci_commit_node(char* nodeName);
int attrNotSupport(omci_me_info_ptr me_info, omci_attr_dscp_ptr omci_attr);
int omci_attr_get_one_table_attr_by_mask( omci_me_info_ptr me_info);
int omci_attr_get_all_data_except_table_attr( omci_me_info_ptr me_info);
int omci_attr_get_old_data_except_table_attr( omci_me_info_ptr me_info);
int omci_me_general_create_op(management_entry_ptr me_entry, omci_me_info_ptr me_info);
int omci_me_general_delete_op(management_entry_ptr me_entry, omci_me_info_ptr me_info);
int omci_me_general_set_op(management_entry_ptr me_entry, omci_me_info_ptr me_info);
int omci_me_general_get_op(management_entry_ptr me_entry, omci_me_info_ptr me_info);
int omci_me_general_get_cur_op(management_entry_ptr me_entry, omci_me_info_ptr me_info);
int omci_me_general_pm_history_create_del_op(management_entry_ptr me_entry, omci_me_info_ptr me_info);
int omci_me_general_pm_history_set_op(management_entry_ptr me_entry, omci_me_info_ptr me_info);
int omci_me_general_pm_history_get_op(management_entry_ptr me_entry, omci_me_info_ptr me_info);
int omci_lib_adpt_update_pm_history_data();
int omci_pm_clear_list_for_mibrest();
uint8_t omci_pm_report_alarm_by_tca_info(tca_notify_info_t info, uint8_t clearAll);
int omci_pm_is_extend_pm_me(uint16_t classId);
void omci_pm_parse_extend_pm_ctrl_block(extend_pm_ctrl_block_ptr info, uint8_t *content);
uint8_t omci_pm_is_end_of_interval_time();


// test msg  check wherer support or not
int ani_g_test_support(omci_me_info_ptr me_info);
int onu_g_test_support(omci_me_info_ptr me_info);
int pptp_pots_uni_test_support(omci_me_info_ptr me_info);

//omci adapt general functions
int omci_adpt_get_one_string_from_inst(uint16_t classId, uint16_t instanceId, char *buffer, uint16_t *length);
int omci_adpt_find_row_buf_first_str(char * rowBuf, uint32_t * fromLen, char * firstStr);
int omci_adpt_set_commit_attriubte(char *name, char *attribute, char *value);

int omci_adpt_report_event(omci_evt_id_t event_id, void *event_val);
int omci_pm_tca_notify();
int omci_adpt_get_pm_pre_data(uint16_t classId, uint16_t instId, void *data, int dataSize);

int getMacMT7530PortRXCnt(EthFramePmStreamCounters_t *data, uint16_t PortId);
int getMacMT7530PortTXCnt(EthFramePmStreamCounters_t *data, uint16_t PortId);

int getVeipPortRxCnt(EthFramePmStreamCounters_t *data);
int getVeipPortTxCnt(EthFramePmStreamCounters_t *data);

int omciStartSwDownloadAction(uint16_t meClassId , omciMeInst_t *meInstant_ptr, omciGenericPayload_t * omciPayLoad, uint8_t msgSrc);
int omciDownloadSecAction(uint16_t meClassId , omciMeInst_t *meInstant_ptr, omciGenericPayload_t * omciPayLoad, uint8_t msgSrc);
int omciEndSwDownloadAction(uint16_t meClassId , omciMeInst_t *meInstant_ptr, omciGenericPayload_t * omciPayLoad, uint8_t msgSrc);
int omciActiveSwAction(uint16_t meClassId , omciMeInst_t *meInstant_ptr, omciGenericPayload_t * omciPayLoad, uint8_t msgSrc);
int omciCommitSwAction(uint16_t meClassId , omciMeInst_t *meInstant_ptr, omciGenericPayload_t * omciPayLoad, uint8_t msgSrc);

extern ECNT_SWITCHMGR_RET switchmgr_lib_get_port_autodetection(uint8_t port, uint8_t *p_auto_detction);
extern ECNT_SWITCHMGR_RET switchmgr_lib_set_port_autodetection(uint8_t port, uint8_t auto_detction);
extern ECNT_SWITCHMGR_RET switchmgr_lib_get_port_configuration_status(uint8_t port, uint8_t *p_cfg);

extern omci_global_info_t omci_info_g;
extern omci_onu_capablity_t  omci_onu_cap_g;
extern attribute_func_t generalAttrFunc;
extern int bbf247_enable;

/*For CMD Msg*/
extern int gponOmciPktTxDbgQ(int len, char *pkts);
extern int gponGetDataFrom;
extern int get_ds_mgnt_data(GPON_10G_DS_MGNT_COUNTER_T *data);
extern int get_us_mgnt_data(GPON_10G_US_MGNT_COUNTER_T *data);
extern omciTLSInfo_t omciTLSInfo;

extern int omci_test_pm_info(void);
extern int (*omci_get_pm_info)(void);

#endif /* _OMCI_ADAPT_COMMON_H_ */
